﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using Convertor.Interface;
using Wpf.CommonTools.SystemExtension;

namespace Convertor.Plugin.UrlEncode
{
    public enum EncodeTypes
    {
        UrlEncode,
        UrlDecode,
        HtmlEncode,
        HtmlDecode,
        Escape,
        UnEscape,
        ToUnicode,
        FromUnicode
    }

    [Serializable]
    public class ConfigContent : IConfigContent, ISerializable, ICloneable, INotifyPropertyChanged
    {
        private EncodeTypes encodeType = EncodeTypes.UrlEncode;

        public EncodeTypes EncodeType
        {
            get { return encodeType; }
            set { encodeType = value; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("ToolTip")); } }
        }

        public ConfigContent()
        {
        }

        public override string ToString()
        {
            return ToolTip;
        }

        #region IToolTip 成员

        public string ToolTip
        {
            get { return string.Format(UILanguage.TryFindResource("Plugin_UrlEncode_Info"), encodeType); }
        }

        #endregion

        #region ICloneable 成员

        public object Clone()
        {
            ConfigContent a = new ConfigContent()
            {
                EncodeType = this.EncodeType
            };
            return a;
        }

        #endregion

        #region ISerializable 成员

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("SortType", EncodeType, typeof(EncodeTypes));
        }

        public ConfigContent(SerializationInfo info, StreamingContext context)
        {
            try
            {
                encodeType = (EncodeTypes)info.GetValue("SortType", typeof(EncodeTypes));
            }
            catch { }
        }

        #endregion

        #region INotifyPropertyChanged 成员

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }


}
